from apscheduler.jobstores.redis import RedisJobStore
from apscheduler.schedulers.tornado import TornadoScheduler
from config import REDIS_HOST, REDIS_PORT, REDIS_PASSWORD, APSCHEDULER_REDIS_DB, APSCHEDULER_MAX_CONNECTIONS

apscheduler_conf = {
    "host": REDIS_HOST,
    "port": REDIS_PORT,
    "db": APSCHEDULER_REDIS_DB,
    "password": REDIS_PASSWORD,
    "max_connections": APSCHEDULER_MAX_CONNECTIONS,
}
job_stores = {
    "redis": RedisJobStore(**apscheduler_conf)
}
scheduler = TornadoScheduler(jobstores=job_stores, timezone='Asia/Shanghai')
